import threading
import time
count = 100

lock = threading.Lock()

def add():
    # 开始锁    如果锁里面的代码块没有执行完毕，就不会切换其他线程执行
    lock.acquire()
    global count
    temp  = count+1
    time.sleep(0.01)
    count = temp
    # 释放锁
    lock.release()


li = []
for i in range(100):
    i = threading.Thread(target=add)
    i.start() # 开启线程
    li.append(i)

for i in li:
    i.join()
print(count)

